<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .box {
            width: 300px;
            height: 300px;
            margin: 100px auto;
            position: relative;
            /* 让背面的紫色盒子保持立体空间 */
            transform-style: preserve-3d;
            transition: transform 0.4s;
        }

        .box:hover{
            transform: rotateY(180deg);
        }

        .front,
        .back {
            width: 100%;
            height: 100%;
            position: absolute;
            left: 0;
            top: 0;
            font-size: 30px;
            text-align: center;
            line-height: 300px;
            border-radius: 50%;
        }

        .front {
            background: pink;
            z-index: 1;
        }

        .back {
            background: purple;
            transform: rotateY(180deg);
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="front">前面哈哈哈</div>
        <div class="back">后面嘿嘿嘿</div>
    </div>
</body>

</html>